<template>
  <div class="layui-tab-content">

    <table class="user-table">
      <thead>
      <tr>
        <th>课程</th>
        <th>班号</th>
        <th>学号</th>
        <th>姓名</th>
        <th>成绩</th>
      </tr>
      </thead>
      <tbody v-for="s in scores" :key="s.studentScoreId">
      <tr>

        <td v-text="s.courseName">1</td>
        <td v-text="s.classId">小明</td>
        <td v-text="s.stuNumber">123456</td>
        <td v-text="s.stuName">123456</td>
        <td v-text="s.score">0</td>
        <td class="admin-manage">
          <a  href="javascript:void(0)" @click="scorePass(s.studentScoreId)">
            审阅通过
          </a>
        </td>

        <td class="manage">
          <a  href="javascript:void(0)" @click="scoreNoPass(s.studentScoreId)">
            审阅不通过
          </a>
        </td>

      </tr>

      </tbody>
    </table>


  </div>
</template>

<script>
export default {
  name: "ScoreList",
  data() {
    return {
      scores :null
    }

  },
  created() {
    this.initScore();
  },
  methods:{
    initScore() {
      const that = this;
      that.axios.get("/api/score_list").then(({ data }) => {
        this.scores = data.data;
      });
    },
    scorePass(id){
      const that = this;
      that.axios.post("/api/score_pass/"+id).then(({ data }) => {
        if (data.flag) {
          that.$message.success("修改成功");
          that.initScore();
        } else {
          that.$message.error(data.message);
        }
      });
    },
    scoreNoPass(id){
      const that = this;
      that.axios.post("/api/score_no_pass/"+id).then(({ data }) => {
        if (data.flag) {
          that.$message.success("修改成功");
          that.initScore();
        } else {
          that.$message.error(data.message);
        }
      });
    }
  }
}
</script>

<style scoped>

</style>
